package expression.primary;

import runtime.ClassMapFactory;
import runtime.RootScopeFactory;
import util.Instance;
import util.Result;
import util.Scope;
import util.Type;
import exception.ExpressionException;
import expression.PrimaryExpression;

public class Creator extends PrimaryExpression {

	String name = null;

	public Creator(Scope scope, String name) {
		this.name = name;
		result = new Result(new Type(name, false), null);
	}

	@Override
	public Result evaluate() throws ExpressionException {
		return new Result(new Type(name, false), new Instance(RootScopeFactory
				.getInstance().getRootScope(), ClassMapFactory.getInstance()
				.getClassMap().get(name)));
	}
	
	public String toString(){
		return "new " + name;
	}

}
